<script lang="ts" setup>
import {ref, onMounted} from 'vue';
import {back, toPath} from "@/util/router/router";

// 响应式数据
const list = ref([
  {key: 'home', name: 'home', color: '#333', backgroundColor: 'white'},
  {key: 'back', name: 'arrow-left', color: '#333', backgroundColor: 'white'},
  {key: 'edit', name: 'edit-pen', color: '#333', backgroundColor: 'white'}
]);

const itemClick = (e) => {
  switch (e.key) {
    case 'home':
      uni.switchTab({
        url: '/pages/index/index'
      });
      break;
    case 'back':
      back()
      break;
    case 'edit':
      const pages = getCurrentPages()
      const cook = pages.find(item => item.route === 'cook/MyCook/MyCook')
      console.log(pages)
      if (cook) {
        console.log(cook)
        toPath('/cook/publish/publish')
      }
      break
  }
}
</script>

<template>
  <up-float-button :isMenu="true" bottom="100rpx" backgroundColor="#ff6d70"
                   :list="list" @item-click="itemClick" right="30rpx">
  </up-float-button>
</template>

<style scoped lang="scss">
:deep(.u-float-button__item) {
  box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
}
</style>